package com.shujia.flink.tf

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala._

object Demo1Map {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    //基于集合构建ds,有界流
    val ds: DataStream[Int] = env.fromCollection(List(1, 2, 3, 4, 5, 6, 7, 8))

    //scala  语言的方式
    val ds1: DataStream[Int] = ds.map(i => i * 2)


    //java 的方式
    val ds2: DataStream[Int] = ds.map(new MapFunction[Int, Int] {
      override def map(value: Int): Int = {
        value * 2
      }
    })

    ds2.print()

    env.execute()


  }

}
